<template>
  <view v-if="listData && listData.length">
    <view v-if="!isOldStyle" class="card-thing" :style="`${styles}`">
      <view class="card-thing-title">
        <text>残疾人证办理 </text>
        <view @click="handleClickMore">更多 <img
          src="https://zjcl-ywpt.oss-cn-hangzhou-zwynet-d01-a.internet.cloud.zj.gov.cn/zlb-zhzc/zhzc-arrow.png" alt="">
      </view>
      </view>

      <view class="card-thing-list" :style="{'background':listData[0].bgcolor}">
        <view class="card-thing-list-title">
          <view class="card-thing-list-title-left">
            <view>
              <text>残疾人证</text>
              <text>异地代办 全域通办</text>
            </view>
          </view>
          <view class="card-thing-list-title-right">
            <svg v-if="!listData[0].bgimage.includes('http')" class="icon" aria-hidden="true">
              <use :xlink:href="'#' + listData[0].bgimage" />
            </svg>
            <img v-else :src="listData[0].bgimage" alt="" class="icon">
          </view>
        </view>
        <view class="card-thing-list-item" v-for="(item, index) in listData" :key="index" @click="handleItemClick(item)">
          <text> {{ item.name }}</text>
          <view> <img
              src="https://zjcl-ywpt.oss-cn-hangzhou-zwynet-d01-a.internet.cloud.zj.gov.cn/zlb-zhzc/zhzc-arrow.png"
              alt="">
          </view>
          <!-- <view v-if="(index % 2) === 0" class="border"></view> -->
        </view>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { ref } from "vue";
const props = defineProps({
  styles: String,
  isOldStyle: Boolean,
  matterList: Array
})

const listData = ref([

])

listData.value = props.matterList.filter((val) => {
  return val.type.includes('1')
})

let styles = ref('')
if (props.styles) {
  styles.value = props.styles?.replace(/"/g, '');
}
const emit = defineEmits(['handleClick', 'handleClickMore'])
const handleItemClick = (item: any) => {
  emit('handleClick', {
    url: item.url,
    content: item.name
  })
}

const handleClickMore = () => {
  emit('handleClickMore', {
    type: 'cardThing'
  })
}
</script>


<style lang="scss" scoped>
.card-thing {
  width: 650upx;
  height: auto;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 1);
  color: rgba(16, 16, 16, 1);
  font-size: 14px;
  margin: 0 auto;
  margin-top: 24upx;
  position: relative;
  overflow: hidden;
  padding: 20upx;

  .card-thing-title {
    color: rgba(54, 58, 68, 1);
    font-size: 36upx;
    font-weight: bold;
    display: flex;
    justify-content: space-between;

    view {
      font-size: 24upx;
      height: 42upx;
      color: #686B73;
      font-weight: normal;
      display: flex;
      align-items: center;

      img {
        width: 24upx;
        height: 24upx;
        margin-left: 5upx;
      }
    }
  }

  .card-thing-list {
    overflow: hidden;
    border-radius: 8px;
    padding: 0 24upx 24upx;
    background: linear-gradient(268.97deg, rgba(243, 251, 254, 1) 0.78%, rgba(244, 248, 255, 1) 99.24%);
    margin-top: 24upx;

    .card-thing-list-title {
      width: 100%;
      display: flex;
      height: 134upx;
      border-bottom: 1px solid rgba(225, 239, 255, 1);
      margin-bottom: 5upx;
      position: relative;

      .card-thing-list-title-left {
        width: 50%;
        display: flex;
        justify-content: space-between;
        align-items: center;

        view:nth-child(1) {
          width: 280upx;
          color: #363A44;
          font-size: 32upx;
          font-weight: normal;
          display: flex;
          flex-direction: column;

          text:nth-child(2) {
            color: #686B73;
            font-size: 24upx;
            margin-top: 12upx;
          }
        }
      }

      .card-thing-list-title-right {
        width: 50%;
        display: flex;
        align-items: center;
        justify-content: space-around;
        .icon {
          width: 148upx;
          height: 136upx;
          position: absolute;
          top: -4upx;
          right: 30upx;
        }

        view {
          width: 53px;
          height: 20px;
          line-height: 17px;
          border-radius: 12px;
          background-color: rgba(255, 255, 255, 1);
          color: #64BEFB;
          font-size: 24upx;
          border: 1px solid rgba(100, 190, 251, 1);
          display: flex;
          align-items: center;
          justify-content: center;
        }

      }
    }

    .card-thing-list-item {
      color: #353A45;
      font-size: 24upx;
      width: 100%;
      float: left;
      height: 40upx;
      line-height: 40upx;
      margin-top: 32upx;
      display: flex;
      justify-content: space-between;
      position: relative;
      overflow: hidden;

      >view {
        display: flex;
        align-items: center;

        img {
          width: 28upx;
          height: 28upx;
        }
      }

      >text:nth-child(1){
        width: 85%;
      }

      .border {
        width: 1px;
        height: 30upx;
        background: #E1EFFF;
        position: absolute;
        top: 5upx;
        right: -15upx;
      }
    }





  }


}
</style>